﻿using DynamicDescriptors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Revit同步插件.UI
{
  /// <summary>
  /// UserControl1.xaml 的交互逻辑
  /// </summary>
  public partial class StartupWindow : Window
  {
    public StartupWindow()
    {
      InitializeComponent();
      mock();
    }

    void mock()
    {
      var instanceToBind = new 自定义属性1();

      // 通过第三方类库，增加属性修饰信息。
      var descriptor = DynamicDescriptor.CreateFromInstance(instanceToBind);
      descriptor.GetDynamicProperty("Name") // by property-name
          .SetDisplayName("名称")
          .SetDescription("第一个属性")
          .SetConverter(new 下拉列表示例()) // drop box sample
          .SetCategory("样例");

      descriptor.GetDynamicProperty((自定义属性1 x) => x.Height) // by expression
          .SetDisplayName("高度")
          .SetDescription("第2个属性")
          .SetCategory("样例");

      descriptor.GetDynamicProperty((自定义属性1 x) => x.Width).SetDisplayName("宽度").SetDescription("第3个属性").SetCategory("样例");

      this.pg.SelectedObject = descriptor;
      this.pg.Tag = instanceToBind;
    }

    private void appBtn_Click(object sender, RoutedEventArgs e)
    {

     MessageBox.Show(  this.pg.Tag?.ToString());
    }
  }
}
